<template>
  <div class="">
    <el-row>
      <el-col :span="24">
        <div class="page-filter mb10 fl">
          <el-form ref="filter" :model="filter" label-width="0">
            <el-form-item class="mr10 mb5 fl">
              <el-date-picker
                v-model="filter.day"
                placeholder="月份"
                type="month"
                format="yyyy-MM"
                value-format="yyyy-MM"
                size="small"
                clearable
                style="width: 100%"
              />
            </el-form-item>
            <el-form-item class="mr10 mb5 fl" style="width: 300px">
              <el-button size="small" @click="app.resetFields($refs['filter'].$parent,'filter')">清 空</el-button>
              <el-button type="primary" size="small" @click="getList">查 询</el-button>
            </el-form-item>
          </el-form>
        </div>
      </el-col>
      <el-col :span="24">
        <el-table :summary-method="getSummaries" show-summary ref="multipleTable" class="search-table" :data="list" border fit highlight-current-row style="width: 100%;">
          <el-table-column label="序号" align="center" width="56px">
            <template slot-scope="{$index}">
              {{ $index + 1 }}
            </template>
          </el-table-column>
          <el-table-column label="名称" width="220px" prop="name" />
          <el-table-column :label="title" align="center">
            <el-table-column align="right" v-for="(item, index) in columns" :key="index" :label="item.label" width="110px" :prop="item.prop" />
          </el-table-column>
        </el-table>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { summary } from '@/api/statistics/statistics'
import page from '@/utils/page'

export default {
  name: '',
  components: { },
  extends: page,
  props: {
    reqList: {
      default: summary,
      type: Function
    }
  },
  data() {
    return {
      title: '',
      columns: [],
      yearsSummaries: [],
      listSummaries: {}
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getListBefore() {
      if(!(this.filter.day && this.filter.day != '')) this.$set(this.filter, 'day', new Date().getFullYear() + '-' + (new Date().getMonth() + 1))
    },
    getListAfter(e) {
      this.columns = e.columns || []
      this.title = e.title || ''
    },
    getSummaries() {
      const sums = []
      sums[0] = '合计'
      sums[1] = this.yearsSummaries[0]
      sums[2] = this.yearsSummaries[1]
      sums[3] = this.yearsSummaries[2]
      sums[4] = 0
      sums[5] = 0
      return sums
    }
  }
}
</script>
<style scoped>
</style>
